package zhongbo.java.air.airingestion.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.Topic;
import zhongbo.java.air.airingestion.listener.RedisLogSubscribeLogChanelListener;

@Configuration
@Slf4j
public class RedisListenerConfig {

    public static String LOG_CHANEL = "log_chanel_zhu";


    public static String FLIGHT_PATH_CHANEL = "flight_path_chanel";
//    public static String INJEST_FLIGHT_PATH = "injest_flight_path";

    @Autowired
    public void configListener(RedisMessageListenerContainer listenerContainer,
                               RedisLogSubscribeLogChanelListener logChanelListener){
        log.info("配置redis监听层");
        // 配置 RedisLogSubscribeListener 监听频道 flight_path_chanel 接收消息
        Topic topic = new PatternTopic(FLIGHT_PATH_CHANEL);
//        Topic injestTopic = new PatternTopic(INJEST_FLIGHT_PATH);
        listenerContainer.addMessageListener(logChanelListener,topic);
//        listenerContainer.addMessageListener(logChanelListener,injestTopic);
    }
}
